import { createRouter, createWebHashHistory } from 'vue-router'
export const Layout = () => import('@/layout/index.vue')

/**
 * 静态路由
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    meta: { hidden: true },
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/system/components/SystemRedirect.vue')
      }
    ]
  },

  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/system/login.vue'),
    meta: { title: '登录', hidden: true }
  },

  {
    path: '/',
    name: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/system/index.vue'),
        meta: {
          title: 'dashboard',
          icon: 'assets/images/menu/sjkb.png',
          affix: true,
          keepAlive: true,
          alwaysShow: false
        }
      },
      {
        path: 'setting',
        component: () => import('@/views/system/components/SystemSetting.vue'),
        name: 'Setting',
        meta: { title: 'System setting', hidden: true }
      },
      {
        path: '401',
        name: '401',
        component: () => import('@/views/system/components/System401.vue'),
        meta: { title: '401', hidden: true }
      },
      {
        path: '404',
        name: '404',
        component: () => import('@/views/system/components/System404.vue'),
        meta: { title: '404', hidden: true }
      }
    ]
  },

  {
    path: '/article',
    name: 'article',
    component: Layout,
    meta: { hidden: true },
    children: [
      {
        path: 'add-edit-view',
        name: 'AddEditView',
        component: () => import('@/views/article/add-edit-view/index.vue'),
        meta: {
          title: '创建方案',
          icon: 'reading',
          hidden: false,
          alwaysShow: false,
          keepAlive: false
        }
      }
    ]
  },
  {
    path: '/platformOperation',
    name: 'platformOperation',
    component: Layout,
    meta: { hidden: true },
    children: [
      {
        path: 'advertising/details',
        name: 'advertisingDetails',
        component: () => import('@/views/platformOperation/advertising/details.vue'),
        meta: {
          title: '创建广告',
          icon: 'reading',
          hidden: false,
          alwaysShow: false,
          keepAlive: false
        }
      }
    ]
  }

  // {
  //   path: '/fabric',
  //   name: 'fabric',
  //   component: Layout,
  //   meta: { title: '海报管理', hidden: false, alwaysShow: false, icon: 'reading', keepAlive: true },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Fabric',
  //       component: () => import('@/views/fabric/index.vue'),
  //       meta: {
  //         title: '海报设计',
  //         icon: 'reading',
  //         hidden: false,
  //         alwaysShow: false,
  //         keepAlive: true
  //       }
  //     }
  //   ]
  // }

  // {
  //   path: '/article',
  //   name: 'article',
  //   component: Layout,
  //   meta: { title: '方案管理', hidden: false, alwaysShow: false, icon: 'reading', keepAlive: true },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'ArticleIndex',
  //       component: () => import('@/views/article/index.vue'),
  //       meta: {
  //         title: '方案管理',
  //         icon: 'reading',
  //         hidden: false,
  //         alwaysShow: false,
  //         keepAlive: true
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/home_page',
  //   name: 'home_page',
  //   component: Layout,
  //   meta: { title: '主页设置', hidden: false, alwaysShow: false, icon: 'reading', keepAlive: true },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'HomePageIndex',
  //       component: () => import('@/views/home_page/index.vue'),
  //       meta: {
  //         title: '主页设置',
  //         icon: 'reading',
  //         hidden: false,
  //         alwaysShow: false,
  //         keepAlive: true
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/order',
  //   name: 'Order',
  //   component: Layout,
  //   meta: { title: '销售订单', hidden: false, alwaysShow: false, icon: 'reading', keepAlive: true },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'OrderIndex',
  //       component: () => import('@/views/order/index.vue'),
  //       meta: {
  //         title: '销售订单',
  //         icon: 'reading',
  //         hidden: false,
  //         alwaysShow: false,
  //         keepAlive: true
  //       }
  //     }
  //   ]
  // },
  // {
  //   path: '/config',
  //   name: 'Config',
  //   component: Layout,
  //   meta: { title: '配置管理', hidden: false, alwaysShow: false, icon: 'reading', keepAlive: true },
  //   children: [
  //     {
  //       path: 'wx',
  //       name: 'ConfigWxIndex',
  //       component: () => import('@/views/config/wx/index.vue'),
  //       meta: {
  //         title: '公众号配置',
  //         icon: 'reading',
  //         hidden: false,
  //         alwaysShow: false,
  //         keepAlive: true
  //       }
  //     },
  //     {
  //       path: 'pay',
  //       name: 'ConfigPayIndex',
  //       component: () => import('@/views/config/pay/index.vue'),
  //       meta: {
  //         title: '支付配置',
  //         icon: 'reading',
  //         hidden: false,
  //         alwaysShow: false,
  //         keepAlive: true
  //       }
  //     },
  //     {
  //       path: 'template_message',
  //       name: 'ConfigTemplateMessageIndex',
  //       component: () => import('@/views/config/template_message/index.vue'),
  //       meta: {
  //         title: '模板消息配置',
  //         icon: 'reading',
  //         hidden: false,
  //         alwaysShow: false,
  //         keepAlive: true
  //       }
  //     }
  //   ]
  // }
]

/**
 * 创建路由
 */
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
  scrollBehavior: () => ({ left: 0, top: 0 })
})

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: '/login' })
}

export default router
